# zstandard.cmake
# 本文件包含着从外部导入 zstandard 所需要的信息

INCLUDE(ExternalProject)

set(ZSTD_ROOT ${PROJECT_SOURCE_DIR}/extern_module_download/zstd)
set(ZSTD_GIT_URL      https://atomgit.com/dangaldb/zstd-Mirror.git)  # 指定git仓库地址
set(ZSTD_CONFIGURE    cd ${ZSTD_ROOT}/src/extern_zstd)
set(ZSTD_MAKE         cd ${ZSTD_ROOT}/src/extern_zstd && make)
set(ZSTD_INSTALL      cd ${ZSTD_ROOT}/src/extern_zstd && make install PREFIX=${ZSTD_ROOT}/output) 

ExternalProject_Add(extern_zstd
        PREFIX            ${ZSTD_ROOT}
        GIT_REPOSITORY    ${ZSTD_GIT_URL}
        CONFIGURE_COMMAND ${ZSTD_CONFIGURE}
        BUILD_COMMAND     ${ZSTD_MAKE}
        INSTALL_COMMAND   ${ZSTD_INSTALL}
        CMAKE_ARGS
        -DCMAKE_INSTALL_PREFIX=${ZSTD_ROOT}/output
        -DBUILD_SHARED_LIBS=OFF
)

INCLUDE_DIRECTORIES(${ZSTD_ROOT}/output/include)
LINK_DIRECTORIES(${ZSTD_ROOT}/output/lib)